from rest_framework.views import APIView as _APIView
from rest_framework.utils.serializer_helpers import ReturnDict
from rest_framework.generics import GenericAPIView
from rest_framework.mixins import ListModelMixin
from base_utils.serializer_error import handel_ser_errors_to_str, get_request_data


class BaseView(_APIView):
    # 将ser.error转成字符串
    def get_errors_str(self, errors: ReturnDict):
        error_str = handel_ser_errors_to_str(errors)
        return error_str

    # 将request.data转成字典
    def get_request_data(self, request, fields: list):
        return get_request_data(request, fields)


class APIView(BaseView):
    pass
